// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import './style.css'
import router from '@/router'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import qs from 'qs'
import VxeUIAll from 'vxe-pc-ui'
import 'vxe-pc-ui/es/style.css'
import VxeUITable from 'vxe-table'
import 'vxe-table/es/style.css'
import VxeUIGantt from 'vxe-gantt'
import 'vxe-gantt/lib/style.css'

async function initApp() {
  const app = createApp(App)
  app.use(ElementPlus)

  const pinia = createPinia()
  pinia.use(piniaPluginPersistedstate)
  app.use(pinia)
  app.use(VxeUIAll)
  app.use(VxeUITable)
  app.use(VxeUIGantt)
  app.use(router)
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
  app.config.globalProperties.$qs = qs
  app.mount('#app')
}

// 启动应用
initApp().catch(err => {
  console.error('应用启动失败', err)
})
